package com.diankangwo.factory.entity;

import com.diankangwo.util.MessageType;
import com.diankangwo.util.getuiUtil;

import java.io.IOException;
import java.util.Date;

public class TdMessage {
    private Integer id;

    private String content;

    private Integer state;

    private Date time;

    private Integer type;

    private String uid;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content == null ? null : content.trim();
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    /**
     * 构造器
     *
     * @param content 内容
     * @param state   状态 是否已读 1已读0未读
     * @param time    时间
     * @param type    类型
     * @param uid     用户UID
     * @param cid     用户个推ID
     */
    public TdMessage(String content, Integer state, Date time, Integer type, String uid, String cid) {
        this.content = content;
        this.state = state;
        this.time = time;
        this.type = type;
        this.uid = uid;
        if (type == MessageType.system.getName() || type == MessageType.activity.getName()) {
            try {
                getuiUtil.getuiToAll(content, content, "");
            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            getuiUtil.getuiToCid(cid, content, content, "", "");
        }

    }
}